granite-rust/compiler/rustc_codegen_ssa/src
bors 836c317426 Auto merge of #83774 - richkadel:zero-based-counters, r=tmandry
Translate counters from Rust 1-based to LLVM 0-based counter ids

A colleague contacted me and asked why Rust's counters start at 1, when
Clangs appear to start at 0. There is a reason why Rust's internal
counters start at 1 (see the docs), and I tried to keep them consistent
when codegenned to LLVM's coverage mapping format. LLVM should be
tolerant of missing counters, but as my colleague pointed out,
`llvm-cov` will silently fail to generate a coverage report for a
function based on LLVM's assumption that the counters are 0-based.

See:
https://github.com/llvm/llvm-project/blob/main/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp#L170

Apparently, if, for example, a function has no branches, it would have
exactly 1 counter. `CounterValues.size()` would be 1, and (with the
1-based index), the counter ID would be 1. This would fail the check
and abort reporting coverage for the function.

It turns out that by correcting for this during coverage map generation,
by subtracting 1 from the Rust Counter ID (both when generating the
counter increment intrinsic call, and when adding counters to the map),
some uncovered functions (including in tests) now appear covered! This
corrects the coverage for a few tests!

r? `@tmandry`
FYI: `@wesleywiser`
2021-04-03 06:27:03 +00:00
..
back rm target specific logic in link_sanitizer_runtime 2021-04-03 00:37:49 +03:00
coverageinfo Translate counters from Rust 1-based to LLVM 0-based counter ids 2021-04-02 17:16:36 -07:00
debuginfo Stop adding '*' at the end of type names for Ref and Slice when computing debug info for MSVC debuggers 2020-11-30 14:31:34 -08:00
mir Translate counters from Rust 1-based to LLVM 0-based counter ids 2021-04-02 17:16:36 -07:00
traits Changes from review comments 2021-03-23 17:02:10 -07:00
base.rs Use a QueryContext for try_mark_green. 2021-02-19 17:51:56 +01:00
common.rs Support LLVM 12 in rustc 2021-02-28 10:19:44 +01:00
glue.rs Change ty.kind to a method 2020-09-04 17:47:51 +02:00
lib.rs Use iter::zip in compiler/ 2021-03-26 09:32:31 -07:00
meth.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
mono_item.rs Use an ItemId inside mir::GlobalAsm. 2021-02-15 19:24:58 +01:00
target_features.rs Rollup merge of #78361 - DevJPM:master, r=workingjubilee 2020-11-18 15:46:19 +01:00