Skip to content

Commit 203d6bf

Browse files
committed
Auto merge of rust-lang#133499 - nikic:no-backend-verify, r=<try>
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. r? `@ghost`
2 parents f2abf82 + d3ad000 commit 203d6bf

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
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

0 commit comments

Comments
 (0)