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.
This commit is contained in:
Nikita Popov 2018-05-30 22:48:20 +02:00
parent ef8cb40c9c
commit 78a16443a3
2 changed files with 12 additions and 7 deletions

View File

@ -461,9 +461,12 @@ fn run_pass_manager(cgcx: &CodegenContext,
unsafe {
let pm = llvm::LLVMCreatePassManager();
llvm::LLVMRustAddAnalysisPasses(tm, pm, llmod);
let pass = llvm::LLVMRustFindAndCreatePass("verify\0".as_ptr() as *const _);
assert!(!pass.is_null());
llvm::LLVMRustAddPass(pm, pass);
if !config.no_verify {
let pass = llvm::LLVMRustFindAndCreatePass("verify\0".as_ptr() as *const _);
assert!(!pass.is_null());
llvm::LLVMRustAddPass(pm, pass);
}
// When optimizing for LTO we don't actually pass in `-O0`, but we force
// it to always happen at least with `-O1`.
@ -494,9 +497,11 @@ fn run_pass_manager(cgcx: &CodegenContext,
}
});
let pass = llvm::LLVMRustFindAndCreatePass("verify\0".as_ptr() as *const _);
assert!(!pass.is_null());
llvm::LLVMRustAddPass(pm, pass);
if !config.no_verify {
let pass = llvm::LLVMRustFindAndCreatePass("verify\0".as_ptr() as *const _);
assert!(!pass.is_null());
llvm::LLVMRustAddPass(pm, pass);
}
time_ext(cgcx.time_passes, None, "LTO passes", ||
llvm::LLVMRunPassManager(pm, llmod));

View File

@ -232,7 +232,7 @@ pub struct ModuleConfig {
emit_obj: bool,
// Miscellaneous flags. These are mostly copied from command-line
// options.
no_verify: bool,
pub no_verify: bool,
no_prepopulate_passes: bool,
no_builtins: bool,
time_passes: bool,