diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2024-12-19 21:53:10 +1100 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2024-12-19 22:03:43 +1100 |
| commit | aced4dcf1047aab08b769b34fae9d4ba7de87f04 (patch) | |
| tree | 40131ad1857c729b5bf690ba554fdfee4e43eb31 /compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/covfun.rs | |
| parent | 837a25dd41a1cc58cee093159a01f73719f330e8 (diff) | |
| download | rust-aced4dcf1047aab08b769b34fae9d4ba7de87f04.tar.gz rust-aced4dcf1047aab08b769b34fae9d4ba7de87f04.zip | |
coverage: Add a synthetic test for when all spans are discarded
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/covfun.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/covfun.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/covfun.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/covfun.rs index 6ce6626f290..5428d776f41 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/covfun.rs +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/covfun.rs @@ -132,6 +132,7 @@ fn fill_region_tables<'tcx>( let make_cov_span = |span: Span| { spans::make_coverage_span(local_file_id, source_map, fn_cov_info, &source_file, span) }; + let discard_all = tcx.sess.coverage_discard_all_spans_in_codegen(); // For each counter/region pair in this function+file, convert it to a // form suitable for FFI. @@ -141,7 +142,17 @@ fn fill_region_tables<'tcx>( // MIR opts, replace those occurrences with zero. let kind = kind.map_terms(|term| if is_zero_term(term) { CovTerm::Zero } else { term }); + // Convert the `Span` into coordinates that we can pass to LLVM, or + // discard the span if conversion fails. In rare, cases _all_ of a + // function's spans are discarded, and the rest of coverage codegen + // needs to handle that gracefully to avoid a repeat of #133606. + // We don't have a good test case for triggering that organically, so + // instead we set `-Zcoverage-options=discard-all-spans-in-codegen` + // to force it to occur. let Some(cov_span) = make_cov_span(span) else { continue }; + if discard_all { + continue; + } match kind { MappingKind::Code(term) => { |
