1
Fork 0

Auto merge of #133499 - nikic:no-backend-verify, r=Mark-Simulacrum

Respect verify-llvm-ir option in the backend

We are currently unconditionally verifying the LLVM IR in the backend (twice), ignoring the value of the verify-llvm-ir option. This has substantial compile-time impact for debug builds.
This commit is contained in:
bors 2024-12-01 04:54:02 +00:00
commit 8ac313bdbe
6 changed files with 10 additions and 13 deletions

View file

@ -61,6 +61,7 @@ fn write_output_file<'ll>(
dwo_output: Option<&Path>, dwo_output: Option<&Path>,
file_type: llvm::FileType, file_type: llvm::FileType,
self_profiler_ref: &SelfProfilerRef, self_profiler_ref: &SelfProfilerRef,
verify_llvm_ir: bool,
) -> Result<(), FatalError> { ) -> Result<(), FatalError> {
debug!("write_output_file output={:?} dwo_output={:?}", output, dwo_output); debug!("write_output_file output={:?} dwo_output={:?}", output, dwo_output);
unsafe { unsafe {
@ -79,6 +80,7 @@ fn write_output_file<'ll>(
output_c.as_ptr(), output_c.as_ptr(),
dwo_output_ptr, dwo_output_ptr,
file_type, file_type,
verify_llvm_ir,
); );
// Record artifact sizes for self-profiling // Record artifact sizes for self-profiling
@ -840,6 +842,7 @@ pub(crate) unsafe fn codegen(
None, None,
llvm::FileType::AssemblyFile, llvm::FileType::AssemblyFile,
&cgcx.prof, &cgcx.prof,
config.verify_llvm_ir,
) )
})?; })?;
} }
@ -877,6 +880,7 @@ pub(crate) unsafe fn codegen(
dwo_out, dwo_out,
llvm::FileType::ObjectFile, llvm::FileType::ObjectFile,
&cgcx.prof, &cgcx.prof,
config.verify_llvm_ir,
) )
})?; })?;
} }

View file

@ -2240,6 +2240,7 @@ unsafe extern "C" {
Output: *const c_char, Output: *const c_char,
DwoOutput: *const c_char, DwoOutput: *const c_char,
FileType: FileType, FileType: FileType,
VerifyIR: bool,
) -> LLVMRustResult; ) -> LLVMRustResult;
pub fn LLVMRustOptimize<'a>( pub fn LLVMRustOptimize<'a>(
M: &'a Module, M: &'a Module,

View file

@ -552,7 +552,7 @@ static CodeGenFileType fromRust(LLVMRustFileType Type) {
extern "C" LLVMRustResult extern "C" LLVMRustResult
LLVMRustWriteOutputFile(LLVMTargetMachineRef Target, LLVMPassManagerRef PMR, LLVMRustWriteOutputFile(LLVMTargetMachineRef Target, LLVMPassManagerRef PMR,
LLVMModuleRef M, const char *Path, const char *DwoPath, LLVMModuleRef M, const char *Path, const char *DwoPath,
LLVMRustFileType RustFileType) { LLVMRustFileType RustFileType, bool VerifyIR) {
llvm::legacy::PassManager *PM = unwrap<llvm::legacy::PassManager>(PMR); llvm::legacy::PassManager *PM = unwrap<llvm::legacy::PassManager>(PMR);
auto FileType = fromRust(RustFileType); auto FileType = fromRust(RustFileType);
@ -577,10 +577,10 @@ LLVMRustWriteOutputFile(LLVMTargetMachineRef Target, LLVMPassManagerRef PMR,
return LLVMRustResult::Failure; return LLVMRustResult::Failure;
} }
auto DBOS = buffer_ostream(DOS); auto DBOS = buffer_ostream(DOS);
unwrap(Target)->addPassesToEmitFile(*PM, BOS, &DBOS, FileType, false); unwrap(Target)->addPassesToEmitFile(*PM, BOS, &DBOS, FileType, !VerifyIR);
PM->run(*unwrap(M)); PM->run(*unwrap(M));
} else { } else {
unwrap(Target)->addPassesToEmitFile(*PM, BOS, nullptr, FileType, false); unwrap(Target)->addPassesToEmitFile(*PM, BOS, nullptr, FileType, !VerifyIR);
PM->run(*unwrap(M)); PM->run(*unwrap(M));
} }

View file

@ -1,9 +0,0 @@
//@ known-bug: #109681
#![crate_type="lib"]
#![feature(linkage)]
#[linkage = "common"]
pub static TEST3: bool = true;
fn main() {}

View file

@ -1,4 +1,4 @@
//@ compile-flags: -g -Copt-level=0 //@ compile-flags: -g -Copt-level=0 -Z verify-llvm-ir
//@ known-bug: #34127 //@ known-bug: #34127
//@ only-x86_64 //@ only-x86_64

View file

@ -2,6 +2,7 @@
//@ failure-status: 101 //@ failure-status: 101
//@ known-bug: #109681 //@ known-bug: #109681
//@ ignore-wasm32 this appears to SIGABRT on wasm, not fail cleanly //@ ignore-wasm32 this appears to SIGABRT on wasm, not fail cleanly
//@ compile-flags: -Z verify-llvm-ir
// This test verifies that we continue to hit the LLVM error for common linkage with non-zero // This test verifies that we continue to hit the LLVM error for common linkage with non-zero
// initializers, since it generates invalid LLVM IR. // initializers, since it generates invalid LLVM IR.