Port Instrument coverage requires llvm 12 to the new struct

This commit is contained in:
SLASHLogin 2022-08-25 23:08:18 +02:00
parent 05ae7ecb74
commit 4c625dc682
3 changed files with 9 additions and 1 deletions

View File

@ -1,5 +1,6 @@
use crate::common::CodegenCx;
use crate::coverageinfo;
use crate::errors::InstrumentCoverageRequiresLLVM12;
use crate::llvm;
use llvm::coverageinfo::CounterMappingRegion;
@ -37,7 +38,7 @@ pub fn finalize<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>) {
// LLVM 12.
let version = coverageinfo::mapping_version();
if version < 4 {
tcx.sess.fatal("rustc option `-C instrument-coverage` requires LLVM 12 or higher.");
tcx.sess.emit_fatal(InstrumentCoverageRequiresLLVM12);
}
debug!("Generating coverage map for CodegenUnit: `{}`", cx.codegen_unit.name());

View File

@ -42,3 +42,7 @@ pub(crate) struct ErrorCreatingImportLibrary<'a> {
pub lib_name: &'a str,
pub error: String,
}
#[derive(SessionDiagnostic)]
#[diag(codegen_llvm::instrument_coverage_requires_llvm_12)]
pub(crate) struct InstrumentCoverageRequiresLLVM12;

View File

@ -15,3 +15,6 @@ codegen_llvm_unknown_feature_fill_request =
codegen_llvm_error_creating_import_library =
Error creating import library for {$lib_name}: {$error}
codegen_llvm_instrument_coverage_requires_llvm_12 =
rustc option `-C instrument-coverage` requires LLVM 12 or higher.