rust/compiler/rustc_codegen_llvm/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 Move SanitizerSet to rustc_target 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 Use iter::zip in compiler/ 2021-03-26 09:32:31 -07:00
llvm Address review comments 2021-03-27 22:16:34 -04:00
abi.rs Enable mutable noalias by default for LLVM 12 2021-03-21 20:10:54 +01:00
allocator.rs Remove redundant to_string calls 2021-02-17 11:25:55 +01:00
asm.rs Always lower asm! to valid HIR 2021-03-13 20:49:32 +00:00
attributes.rs Move SanitizerSet to rustc_target 2021-04-03 00:37:49 +03:00
base.rs Move SanitizerSet to rustc_target 2021-04-03 00:37:49 +03:00
builder.rs Use iter::zip in compiler/ 2021-03-26 09:32:31 -07:00
callee.rs rustc_target: Rename some target options to avoid tautology 2020-11-08 17:29:13 +03:00
common.rs Update and improve rustc_codegen_{llvm,ssa} docs 2020-12-22 19:42:23 -08:00
consts.rs Replace const_cstr with cstr crate 2021-02-14 09:45:35 +11:00
context.rs Auto merge of #83387 - cuviper:min-llvm-10, r=nagisa 2021-03-25 13:11:18 +00:00
declare.rs Make declare_cfn more flexible 2021-01-23 17:19:49 -05:00
intrinsic.rs correct macro names 2021-03-19 03:47:13 +08:00
lib.rs Use iter::zip in compiler/ 2021-03-26 09:32:31 -07:00
llvm_util.rs Auto merge of #82980 - tmiasko:import-cold-multiplier, r=michaelwoerister 2021-03-26 11:57:44 +00:00
metadata.rs fix review 2021-02-25 04:21:12 +03:00
mono_item.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
type_.rs Use ty::{IntTy,UintTy,FloatTy} in rustc 2021-01-18 21:09:30 +01:00
type_of.rs Revert "cg_llvm: fewer_names in uncached_llvm_type" 2020-12-17 16:40:47 +00:00
va_arg.rs Add big-endian support for AArch64 va_arg 2021-01-27 22:47:56 +00:00
value.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00