Skip to content

Commit 8ac313b

Browse files
committed
Auto merge of rust-lang#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.
2 parents 4af7fa7 + fc9f727 commit 8ac313b

File tree

6 files changed

+10
-13
lines changed

6 files changed

+10
-13
lines changed

compiler/rustc_codegen_llvm/src/back/write.rs

+4
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ fn write_output_file<'ll>(
6161
dwo_output: Option<&Path>,
6262
file_type: llvm::FileType,
6363
self_profiler_ref: &SelfProfilerRef,
64+
verify_llvm_ir: bool,
6465
) -> Result<(), FatalError> {
6566
debug!("write_output_file output={:?} dwo_output={:?}", output, dwo_output);
6667
unsafe {
@@ -79,6 +80,7 @@ fn write_output_file<'ll>(
7980
output_c.as_ptr(),
8081
dwo_output_ptr,
8182
file_type,
83+
verify_llvm_ir,
8284
);
8385

8486
// Record artifact sizes for self-profiling
@@ -840,6 +842,7 @@ pub(crate) unsafe fn codegen(
840842
None,
841843
llvm::FileType::AssemblyFile,
842844
&cgcx.prof,
845+
config.verify_llvm_ir,
843846
)
844847
})?;
845848
}
@@ -877,6 +880,7 @@ pub(crate) unsafe fn codegen(
877880
dwo_out,
878881
llvm::FileType::ObjectFile,
879882
&cgcx.prof,
883+
config.verify_llvm_ir,
880884
)
881885
})?;
882886
}

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2240,6 +2240,7 @@ unsafe extern "C" {
22402240
Output: *const c_char,
22412241
DwoOutput: *const c_char,
22422242
FileType: FileType,
2243+
VerifyIR: bool,
22432244
) -> LLVMRustResult;
22442245
pub fn LLVMRustOptimize<'a>(
22452246
M: &'a Module,

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ static CodeGenFileType fromRust(LLVMRustFileType Type) {
552552
extern "C" LLVMRustResult
553553
LLVMRustWriteOutputFile(LLVMTargetMachineRef Target, LLVMPassManagerRef PMR,
554554
LLVMModuleRef M, const char *Path, const char *DwoPath,
555-
LLVMRustFileType RustFileType) {
555+
LLVMRustFileType RustFileType, bool VerifyIR) {
556556
llvm::legacy::PassManager *PM = unwrap<llvm::legacy::PassManager>(PMR);
557557
auto FileType = fromRust(RustFileType);
558558

@@ -577,10 +577,10 @@ LLVMRustWriteOutputFile(LLVMTargetMachineRef Target, LLVMPassManagerRef PMR,
577577
return LLVMRustResult::Failure;
578578
}
579579
auto DBOS = buffer_ostream(DOS);
580-
unwrap(Target)->addPassesToEmitFile(*PM, BOS, &DBOS, FileType, false);
580+
unwrap(Target)->addPassesToEmitFile(*PM, BOS, &DBOS, FileType, !VerifyIR);
581581
PM->run(*unwrap(M));
582582
} else {
583-
unwrap(Target)->addPassesToEmitFile(*PM, BOS, nullptr, FileType, false);
583+
unwrap(Target)->addPassesToEmitFile(*PM, BOS, nullptr, FileType, !VerifyIR);
584584
PM->run(*unwrap(M));
585585
}
586586

tests/crashes/109681.rs

-9
This file was deleted.

tests/crashes/34127.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ compile-flags: -g -Copt-level=0
1+
//@ compile-flags: -g -Copt-level=0 -Z verify-llvm-ir
22
//@ known-bug: #34127
33
//@ only-x86_64
44

tests/ui/linkage-attr/common-linkage-non-zero-init.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//@ failure-status: 101
33
//@ known-bug: #109681
44
//@ ignore-wasm32 this appears to SIGABRT on wasm, not fail cleanly
5+
//@ compile-flags: -Z verify-llvm-ir
56

67
// This test verifies that we continue to hit the LLVM error for common linkage with non-zero
78
// initializers, since it generates invalid LLVM IR.

0 commit comments

Comments
 (0)