Skip to content

Commit

Permalink
Auto merge of #133499 - nikic:no-backend-verify, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Nov 30, 2024
2 parents 76f3ff6 + fc9f727 commit c43d4f5
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 13 deletions.
4 changes: 4 additions & 0 deletions compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ fn write_output_file<'ll>(
dwo_output: Option<&Path>,
file_type: llvm::FileType,
self_profiler_ref: &SelfProfilerRef,
verify_llvm_ir: bool,
) -> Result<(), FatalError> {
debug!("write_output_file output={:?} dwo_output={:?}", output, dwo_output);
unsafe {
Expand All @@ -79,6 +80,7 @@ fn write_output_file<'ll>(
output_c.as_ptr(),
dwo_output_ptr,
file_type,
verify_llvm_ir,
);

// Record artifact sizes for self-profiling
Expand Down Expand Up @@ -840,6 +842,7 @@ pub(crate) unsafe fn codegen(
None,
llvm::FileType::AssemblyFile,
&cgcx.prof,
config.verify_llvm_ir,
)
})?;
}
Expand Down Expand Up @@ -877,6 +880,7 @@ pub(crate) unsafe fn codegen(
dwo_out,
llvm::FileType::ObjectFile,
&cgcx.prof,
config.verify_llvm_ir,
)
})?;
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2240,6 +2240,7 @@ unsafe extern "C" {
Output: *const c_char,
DwoOutput: *const c_char,
FileType: FileType,
VerifyIR: bool,
) -> LLVMRustResult;
pub fn LLVMRustOptimize<'a>(
M: &'a Module,
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ static CodeGenFileType fromRust(LLVMRustFileType Type) {
extern "C" LLVMRustResult
LLVMRustWriteOutputFile(LLVMTargetMachineRef Target, LLVMPassManagerRef PMR,
LLVMModuleRef M, const char *Path, const char *DwoPath,
LLVMRustFileType RustFileType) {
LLVMRustFileType RustFileType, bool VerifyIR) {
llvm::legacy::PassManager *PM = unwrap<llvm::legacy::PassManager>(PMR);
auto FileType = fromRust(RustFileType);

Expand All @@ -577,10 +577,10 @@ LLVMRustWriteOutputFile(LLVMTargetMachineRef Target, LLVMPassManagerRef PMR,
return LLVMRustResult::Failure;
}
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));
} else {
unwrap(Target)->addPassesToEmitFile(*PM, BOS, nullptr, FileType, false);
unwrap(Target)->addPassesToEmitFile(*PM, BOS, nullptr, FileType, !VerifyIR);
PM->run(*unwrap(M));
}

Expand Down
9 changes: 0 additions & 9 deletions tests/crashes/109681.rs

This file was deleted.

2 changes: 1 addition & 1 deletion tests/crashes/34127.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ compile-flags: -g -Copt-level=0
//@ compile-flags: -g -Copt-level=0 -Z verify-llvm-ir
//@ known-bug: #34127
//@ only-x86_64

Expand Down
1 change: 1 addition & 0 deletions tests/ui/linkage-attr/common-linkage-non-zero-init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//@ failure-status: 101
//@ known-bug: #109681
//@ 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
// initializers, since it generates invalid LLVM IR.
Expand Down

0 comments on commit c43d4f5

Please sign in to comment.