]> git.lizzy.rs Git - rust.git/commitdiff
Respect -Z no-verify during LTO
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 30 May 2018 20:48:20 +0000 (22:48 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 12 Jun 2018 18:50:21 +0000 (20:50 +0200)
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.

src/librustc_codegen_llvm/back/lto.rs
src/librustc_codegen_llvm/back/write.rs

index 96eda50d7883573340eb1aff7e2628df307ddbbd..415dd605220c2d37b21e3ad5c3083aa9079dca9f 100644 (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));
index baab3c618be58e84a5c6e3820c907976be1d5301..b34dae98d7a3a9f5fc55b5f6960ae789cb163570 100644 (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,