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
![Screen-Recording-2020-08-21-at-2](https://user-images.githubusercontent.com/3827298/90972923-ff417880-e4d1-11ea-92bb-8713c6198f6d.gif)
2020-08-27 16:13:04 -05:00
|
|
|
# needs-profiler-support
|
|
|
|
|
|
|
|
# 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`.
|
2020-10-05 11:26:30 -05:00
|
|
|
# See ../coverage/coverage_tools.mk for more information.
|
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
![Screen-Recording-2020-08-21-at-2](https://user-images.githubusercontent.com/3827298/90972923-ff417880-e4d1-11ea-92bb-8713c6198f6d.gif)
2020-08-27 16:13:04 -05:00
|
|
|
|
2020-10-05 11:26:30 -05:00
|
|
|
-include ../coverage/coverage_tools.mk
|
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
![Screen-Recording-2020-08-21-at-2](https://user-images.githubusercontent.com/3827298/90972923-ff417880-e4d1-11ea-92bb-8713c6198f6d.gif)
2020-08-27 16:13:04 -05:00
|
|
|
|
2020-10-05 11:26:30 -05:00
|
|
|
BASEDIR=../coverage-llvmir-base
|
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
![Screen-Recording-2020-08-21-at-2](https://user-images.githubusercontent.com/3827298/90972923-ff417880-e4d1-11ea-92bb-8713c6198f6d.gif)
2020-08-27 16:13:04 -05:00
|
|
|
|
|
|
|
ifeq ($(UNAME),Darwin)
|
|
|
|
INSTR_PROF_DATA_SUFFIX=,regular,live_support
|
|
|
|
DATA_SECTION_PREFIX=__DATA,
|
|
|
|
LLVM_COV_SECTION_PREFIX=__LLVM_COV,
|
|
|
|
else
|
|
|
|
INSTR_PROF_DATA_SUFFIX=
|
|
|
|
DATA_SECTION_PREFIX=
|
|
|
|
LLVM_COV_SECTION_PREFIX=
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(LINK_DEAD_CODE),yes)
|
|
|
|
DEFINE_INTERNAL=define hidden
|
|
|
|
else
|
|
|
|
DEFINE_INTERNAL=define internal
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef IS_WINDOWS
|
|
|
|
LLVM_FILECHECK_OPTIONS=\
|
|
|
|
-check-prefixes=CHECK,WINDOWS \
|
|
|
|
-DPRIVATE_GLOBAL='internal global' \
|
|
|
|
-DDEFINE_INTERNAL='$(DEFINE_INTERNAL)' \
|
|
|
|
-DINSTR_PROF_DATA='.lprfd$$M' \
|
|
|
|
-DINSTR_PROF_NAME='.lprfn$$M' \
|
|
|
|
-DINSTR_PROF_CNTS='.lprfc$$M' \
|
|
|
|
-DINSTR_PROF_VALS='.lprfv$$M' \
|
|
|
|
-DINSTR_PROF_VNODES='.lprfnd$$M' \
|
|
|
|
-DINSTR_PROF_COVMAP='.lcovmap$$M' \
|
|
|
|
-DINSTR_PROF_ORDERFILE='.lorderfile$$M'
|
|
|
|
else
|
|
|
|
LLVM_FILECHECK_OPTIONS=\
|
|
|
|
-check-prefixes=CHECK \
|
|
|
|
-DPRIVATE_GLOBAL='private global' \
|
|
|
|
-DDEFINE_INTERNAL='$(DEFINE_INTERNAL)' \
|
|
|
|
-DINSTR_PROF_DATA='$(DATA_SECTION_PREFIX)__llvm_prf_data$(INSTR_PROF_DATA_SUFFIX)' \
|
|
|
|
-DINSTR_PROF_NAME='$(DATA_SECTION_PREFIX)__llvm_prf_names' \
|
|
|
|
-DINSTR_PROF_CNTS='$(DATA_SECTION_PREFIX)__llvm_prf_cnts' \
|
|
|
|
-DINSTR_PROF_VALS='$(DATA_SECTION_PREFIX)__llvm_prf_vals' \
|
|
|
|
-DINSTR_PROF_VNODES='$(DATA_SECTION_PREFIX)__llvm_prf_vnds' \
|
|
|
|
-DINSTR_PROF_COVMAP='$(LLVM_COV_SECTION_PREFIX)__llvm_covmap' \
|
|
|
|
-DINSTR_PROF_ORDERFILE='$(DATA_SECTION_PREFIX)__llvm_orderfile'
|
|
|
|
endif
|
|
|
|
|
|
|
|
all:
|
|
|
|
# Compile the test program with non-experimental coverage instrumentation, and generate LLVM IR
|
|
|
|
#
|
|
|
|
# Note: `-Clink-dead-code=no` disables the option, needed because the option is automatically
|
|
|
|
# enabled for some platforms, but not for Windows MSVC (due to Issue #76038). The state of this
|
|
|
|
# option affects the generated MIR and coverage, so it is enabled for tests to ensure the
|
|
|
|
# tests results are the same across platforms.
|
|
|
|
$(RUSTC) $(BASEDIR)/testprog.rs \
|
|
|
|
-Zinstrument-coverage \
|
|
|
|
-Clink-dead-code=$(LINK_DEAD_CODE) \
|
|
|
|
--emit=llvm-ir
|
|
|
|
|
|
|
|
cat "$(TMPDIR)"/testprog.ll | "$(LLVM_FILECHECK)" $(BASEDIR)/filecheck.testprog.txt $(LLVM_FILECHECK_OPTIONS)
|