Tools, tests, and experimenting with MIR-derived coverage counters
Adds a new mir_dump output file in HTML/CSS to visualize code regions
and the MIR features that they came from (including overlapping spans).
See example below:
Includes a basic, MIR-block-based implementation of coverage injection,
available via `-Zexperimental-coverage`. This implementation has known
flaws and omissions, but is simple enough to validate the new tools and
tests.
The existing `-Zinstrument-coverage` option currently enables
function-level coverage only, which at least appears to generate
accurate coverage reports at that level.
Experimental coverage is not accurate at this time. When branch coverage
works as intended, the `-Zexperimental-coverage` option should be
removed.
This PR replaces the bulk of PR #75828, with the remaining parts of
that PR distributed among other separate and indentpent PRs.
This PR depends on three of those other PRs: #76000, #76002, and
Rust compiler MCP rust-lang/compiler-team#278
Relevant issue: #34701 - Implement support for LLVMs code coverage
instrumentation

2020-08-27 14:13:04 -07:00
|
|
|
# Common Makefile include for Rust `run-make-fulldeps/instrument-coverage-* tests. Include this
|
|
|
|
|
# file with the line:
|
|
|
|
|
#
|
|
|
|
|
# -include ../instrument-coverage/coverage_tools.mk
|
|
|
|
|
#
|
|
|
|
|
# To enable the Rust compiler option `-C link-dead-code`, also set the following variable
|
|
|
|
|
# *BEFORE* the `-include` line:
|
|
|
|
|
#
|
|
|
|
|
# LINK_DEAD_CODE=yes
|
|
|
|
|
|
|
|
|
|
-include ../tools.mk
|
|
|
|
|
|
|
|
|
|
ifndef LINK_DEAD_CODE
|
|
|
|
|
LINK_DEAD_CODE=no
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
# ISSUE(76038): When targeting MSVC, Rust binaries built with both `-Z instrument-coverage` and
|
|
|
|
|
# `-C link-dead-code` typically crash (with a seg-fault) or at best generate an empty `*.profraw`
|
|
|
|
|
# file, required for coverage reports.
|
|
|
|
|
#
|
|
|
|
|
# Enabling `-C link-dead-code` is preferred when compiling with `-Z instrument-coverage`, so
|
|
|
|
|
# `-C link-dead-code` is automatically enabled for all platform targets _except_ MSVC.
|
|
|
|
|
#
|
|
|
|
|
# Making the state of `-C link-dead-code` platform-dependent creates a problem for cross-platform
|
|
|
|
|
# tests because the injected counters, coverage reports, and some low-level output can be different,
|
|
|
|
|
# depending on the `-C link-dead-code` setting. For example, coverage reports will not report any
|
|
|
|
|
# coverage for a dead code region when the `-C link-dead-code` option is disabled, but with the
|
|
|
|
|
# option enabled, those same regions will show coverage counter values (of zero, of course).
|
|
|
|
|
#
|
|
|
|
|
# To ensure cross-platform `-Z instrument-coverage` generate consistent output, the
|
|
|
|
|
# `-C link-dead-code` option is always explicitly enabled or disabled.
|
|
|
|
|
#
|
|
|
|
|
# Since tests that execute binaries enabled with both `-Z instrument-coverage` and
|
|
|
|
|
# `-C link-dead-code` are known to fail, those tests will need the `# ignore-msvc` setting.
|
|
|
|
|
#
|
|
|
|
|
# If and when the above issue is resolved, the `# ignore-msvc` option can be removed, and the
|
|
|
|
|
# tests can be simplified to always test with `-C link-dead-code`.
|
|
|
|
|
|
|
|
|
|
UNAME = $(shell uname)
|
2020-10-30 16:09:05 -07:00
|
|
|
|
|
|
|
|
# FIXME(richkadel): Can any of the features tested by `run-make-fulldeps/coverage-*` tests be tested
|
|
|
|
|
# just as completely by more focused unit tests of the code logic itself, to reduce the number of
|
|
|
|
|
# test result files generated and maintained, and to help identify specific test failures and root
|
|
|
|
|
# causes more easily?
|